if (info->action)
g_object_unref (info->action);
+ if (info->proxy)
+ g_object_unref (info->proxy);
+ if (info->extra)
+ g_object_unref (info->extra);
g_free (info->name);
g_chunk_free (info, merge_node_chunk);
if (info->proxy == NULL)
{
info->proxy = gtk_menu_bar_new ();
+ g_object_ref (info->proxy);
+ gtk_object_sink (info->proxy);
gtk_widget_set_name (info->proxy, info->name);
gtk_widget_show (info->proxy);
g_signal_emit (self, ui_manager_signals[ADD_WIDGET], 0, info->proxy);
break;
case NODE_TYPE_POPUP:
if (info->proxy == NULL)
- info->proxy = gtk_menu_new ();
+ {
+ info->proxy = gtk_menu_new ();
+ g_object_ref (info->proxy);
+ gtk_object_sink (info->proxy);
+ }
gtk_widget_set_name (info->proxy, info->name);
break;
case NODE_TYPE_MENU:
gtk_action_disconnect_proxy (info->action, info->proxy);
gtk_container_remove (GTK_CONTAINER (info->proxy->parent),
info->proxy);
+ g_object_unref (info->proxy);
info->proxy = NULL;
}
/* create proxy if needed ... */
GtkWidget *filler;
info->proxy = gtk_action_create_menu_item (action);
+ g_object_ref (info->proxy);
+ gtk_object_sink (info->proxy);
menu = gtk_menu_new ();
gtk_widget_set_name (info->proxy, info->name);
gtk_widget_set_name (menu, info->name);
if (info->proxy == NULL)
{
info->proxy = gtk_toolbar_new ();
+ g_object_ref (info->proxy);
+ gtk_object_sink (info->proxy);
gtk_widget_set_name (info->proxy, info->name);
gtk_widget_show (info->proxy);
g_signal_emit (self, ui_manager_signals[ADD_WIDGET], 0, info->proxy);
{
gtk_container_remove (GTK_CONTAINER (info->proxy->parent),
info->proxy);
+ g_object_unref (info->proxy);
info->proxy = NULL;
}
if (info->extra)
{
gtk_container_remove (GTK_CONTAINER (info->extra->parent),
info->extra);
+ g_object_unref (info->extra);
info->extra = NULL;
}
}
if (find_menu_position (node, &menushell, &pos))
{
info->proxy = gtk_separator_menu_item_new ();
+ g_object_ref (info->proxy);
+ gtk_object_sink (info->proxy);
g_object_set_data (G_OBJECT (info->proxy),
"gtk-separator-mode",
GINT_TO_POINTER (SEPARATOR_MODE_HIDDEN));
NODE_INFO (node)->proxy, pos);
info->extra = gtk_separator_menu_item_new ();
+ g_object_ref (info->extra);
+ gtk_object_sink (info->extra);
g_object_set_data (G_OBJECT (info->extra),
"gtk-separator-mode",
GINT_TO_POINTER (SEPARATOR_MODE_HIDDEN));
{
gtk_container_remove (GTK_CONTAINER (info->proxy->parent),
info->proxy);
+ g_object_unref (info->proxy);
info->proxy = NULL;
}
if (info->extra)
{
gtk_container_remove (GTK_CONTAINER (info->extra->parent),
info->extra);
+ g_object_unref (info->extra);
info->extra = NULL;
}
}
item = gtk_separator_tool_item_new ();
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, pos);
info->proxy = GTK_WIDGET (item);
+ g_object_ref (info->proxy);
+ gtk_object_sink (info->proxy);
g_object_set_data (G_OBJECT (info->proxy),
"gtk-separator-mode",
GINT_TO_POINTER (SEPARATOR_MODE_HIDDEN));
item = gtk_separator_tool_item_new ();
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, pos+1);
info->extra = GTK_WIDGET (item);
+ g_object_ref (info->extra);
+ gtk_object_sink (info->extra);
g_object_set_data (G_OBJECT (info->extra),
"gtk-separator-mode",
GINT_TO_POINTER (SEPARATOR_MODE_HIDDEN));
gtk_action_disconnect_proxy (info->action, info->proxy);
gtk_container_remove (GTK_CONTAINER (info->proxy->parent),
info->proxy);
+ g_object_unref (info->proxy);
info->proxy = NULL;
}
/* create proxy if needed ... */
if (find_menu_position (node, &menushell, &pos))
{
info->proxy = gtk_action_create_menu_item (action);
+ g_object_ref (info->proxy);
+ gtk_object_sink (info->proxy);
gtk_widget_set_name (info->proxy, info->name);
gtk_menu_shell_insert (GTK_MENU_SHELL (menushell),
break;
case NODE_TYPE_TOOLITEM:
/* remove the proxy if it is of the wrong type ... */
- if (info->proxy && G_OBJECT_TYPE (info->proxy) !=
- GTK_ACTION_GET_CLASS (action)->toolbar_item_type)
+ if (info->proxy &&
+ G_OBJECT_TYPE (info->proxy) != GTK_ACTION_GET_CLASS (action)->toolbar_item_type)
{
g_signal_handlers_disconnect_by_func (info->proxy,
G_CALLBACK (update_smart_separators),
gtk_action_disconnect_proxy (info->action, info->proxy);
gtk_container_remove (GTK_CONTAINER (info->proxy->parent),
info->proxy);
+ g_object_unref (info->proxy);
info->proxy = NULL;
}
/* create proxy if needed ... */
if (find_toolbar_position (node, &toolbar, &pos))
{
info->proxy = gtk_action_create_tool_item (action);
+ g_object_ref (info->proxy);
+ gtk_object_sink (info->proxy);
gtk_widget_set_name (info->proxy, info->name);
gtk_toolbar_insert (GTK_TOOLBAR (toolbar),
{
gtk_container_remove (GTK_CONTAINER (info->proxy->parent),
info->proxy);
+ g_object_unref (info->proxy);
info->proxy = NULL;
}
GtkToolItem *item = gtk_separator_tool_item_new ();
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, pos);
info->proxy = GTK_WIDGET (item);
+ g_object_ref (info->proxy);
+ gtk_object_sink (info->proxy);
gtk_widget_set_no_show_all (info->proxy, TRUE);
g_object_set_data (G_OBJECT (info->proxy),
"gtk-separator-mode",
{
gtk_container_remove (GTK_CONTAINER (info->proxy->parent),
info->proxy);
+ g_object_unref (info->proxy);
info->proxy = NULL;
}
if (find_menu_position (node, &menushell, &pos))
{
info->proxy = gtk_separator_menu_item_new ();
+ g_object_ref (info->proxy);
+ gtk_object_sink (info->proxy);
gtk_widget_set_no_show_all (info->proxy, TRUE);
g_object_set_data (G_OBJECT (info->proxy),
"gtk-separator-mode",
" <toolitem name=\"justify-fill\" action=\"justify-fill\" />\n"
" <separator name=\"sep11\"/>\n"
" <toolitem name=\"quit\" action=\"quit\" />\n"
-" </toolbar>\n";
+" </toolbar>\n"
+" <popup name=\"popup\">\n"
+" <menuitem name=\"popcut\" action=\"cut\" />\n"
+" <menuitem name=\"popcopy\" action=\"copy\" />\n"
+" <menuitem name=\"poppaste\" action=\"paste\" />\n"
+" </popup>\n";
static void
add_widget (GtkUIManager *merge,
GtkWidget *hbox, *spinbutton, *button;
GError *error = NULL;
+ merge = gtk_ui_manager_new ();
+
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (window), -1, -1);
gtk_window_set_title (GTK_WINDOW (window), "Action Test");
+ g_signal_connect_swapped (window, "destroy", G_CALLBACK (g_object_unref), merge);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
box = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (window), box);
gtk_widget_show (box);
- merge = gtk_ui_manager_new ();
gtk_ui_manager_insert_action_group (merge, action_group, 0);
g_signal_connect (merge, "add_widget", G_CALLBACK (add_widget), box);
gtk_main ();
+#ifdef DEBUG_UI_MANAGER
+ {
+ GList *action;
+
+ for (action = gtk_action_group_list_actions (action_group);
+ action;
+ action = action->next)
+ {
+ GtkAction *a = action->data;
+ g_print ("action %s ref count %d\n",
+ gtk_action_get_name (a), G_OBJECT (a)->ref_count);
+ }
+ }
+#endif
+
g_object_unref (action_group);
gtk_accel_map_save ("accels");